<template>
	<view>
		<view v-for="(cursePlan,index) in cursePlanList" :key="index">
			<text style="display: inline-block;">第{{cursePlan.cursePlanNo}}节课</text>
			<text style="margin-left: 60%;text-decoration:underline;display: inline-block;" @tap="toEdit(cursePlan.cursePlanId)">编辑</text>
			<view style="height: 50rpx;"></view>
		</view>
		<button class="btn-bottom" type="primary" @click="complete()">完成</button>
	</view>
</template>

<script>
	import base from '@/common/base.js'
	export default {
		data() {
			return {
				cursePlanList: [],
				path: "/pages/user/course/editEachCourse",
				curseId: 0,
			}
		},
		onLoad(options) {
			this.curseId = options.curseId;
			this.getCursePlanList(options.curseId);
		},
		onBackPress() {
			uni.request({
				url: base.urlPrefix + 'yoga_app/curse/coachUpdateCurseStatusToNoPassByCurseId',
				data:{
					curseId:this.curseId
				}
			});
			base.isEdittingNotPassCursePlan=false;
			uni.navigateTo({
				url: "/pages/user/course/editNotPassCourseBaseMessage?curseId=" + this.curseId
			})
		},
		methods: {
			getCursePlanList(curseId) {
				uni.request({
					url: base.urlPrefix + 'yoga_app/curse-plan/coachGetOrderCursePlanListByCurseId',
					data: {
						curseId: curseId
					},
					success: (res) => {
						this.cursePlanList = res.data.list;
					}
				})
			},
			toEdit(cursePlanId) {
				base.cursePlanId=cursePlanId;
				uni.navigateTo({
					url: "/pages/user/course/editEachNotPassCourse?cursePlanId=" + cursePlanId
				})
			},
			complete() {
			base.isEdittingNotPassCursePlan=false;
				uni.request({
					url:base.urlPrefix+'yoga_app/curse/coachSubmitCurseRequest',
					data:{
						curseId:this.curseId
					}
				})
				uni.showToast({
					title: '更新成功',
					icon: 'success'
				});
				uni.switchTab({
					url: "/pages/tabBar/user/user",
				});
			}
		}
	}
</script>

<style>
	.inp {
		display: flex;
		align-items: center;
		height: 50rpx;
		padding: 12rpx 13rpx;
		border-radius: 5rpx;
	}

	.input-label {
		background-color: #A7A7A7;
	}

	.bottom {
		margin-bottom: 0rpx;
	}

	.btn-bottom {
		margin-bottom: 0rpx;
		margin-right: 0rpx;
	}
</style>
